--[[ -------------------------------------------------------
MUSHclient MiniWindow Position.

Contains the possible position values for a MiniWindow,
as well as utility functions for validation and printing.

$URL: http://mushclient-lua-objects.googlecode.com/svn/branches/working/Daesilme/MUSHclient/MiniWindow/Position.lua $

Copyright (C) 2009 Daesilme (Daniel W. Drake)

This file is part of mushclient-lua-objects.

mushclient-lua-objects is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software
Foundation, either version 2 of the License, or (at your
option) any later version.

mushclient-lua-objects is distributed in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public
License along with mushclient-lua-objects.  If not, see
<http://www.gnu.org/licenses/>.
------------------------------------------------------- ]]--

require("class");

class "Position";

local PositionClass = Position:classtable();

------------------------------------------------------------
-- PUBLIC CLASS PROPERTIES
------------------------------------------------------------

-- Possible Values for MiniWindow Position
PositionClass.STRETCH_TO_OUTPUT						=	0;
PositionClass.STRETCH_TO_OUTPUT_WITH_ASPECT_RATIO	=	1;
PositionClass.STRETCH_TO_OWNER						=	2;
PositionClass.STRETCH_TO_OWNER_WITH_ASPECT_RATIO	=	3;
PositionClass.TOP_LEFT								=	4;
PositionClass.TOP_CENTER							=	5;
PositionClass.TOP_RIGHT								=	6;
PositionClass.CENTER_RIGHT							=	7;
PositionClass.BOTTOM_RIGHT							=	8;
PositionClass.BOTTOM_CENTER							=	9;
PositionClass.BOTTOM_LEFT							=	10;
PositionClass.CENTER_LEFT							=	11;
PositionClass.CENTER								=	12;
PositionClass.TILE									=	13;

------------------------------------------------------------
-- PUBLIC CLASS METHODS
------------------------------------------------------------

-- Returns if the value @pos is a valid MiniWindow value.
function PositionClass:isValid(pos)
	return (
		(pos ~= nil)	and
		(pos >= 0)		and
		(pos <= 13)
	);
end   -- PositionClass:isValid(pos)

-- Returns a string representation of the MiniWindow position
-- specified by @pos.
function PositionClass:toString(pos)
	if(self:isValid(pos)) then
		return self.private.POSITION_TO_STRING[pos];
	else
		error(
			string.format(
				"[%s] is not a valid MiniWindow Position",
				tostring(pos)
			)
		);
	end
end   -- PositionClass:toString(pos)

------------------------------------------------------------
-- PUBLIC OBJECT PROPERTIES
------------------------------------------------------------

------------------------------------------------------------
-- PUBLIC OBJECT METHODS
------------------------------------------------------------

-- Constructor
-- Raises error to prevent instantiation
function Position:initialize()
	error("MUSHclient.MiniWindow.Position cannot be instantiated.");
end   -- Position:initialize()


------------------------------------------------------------
-- PRIVATE CLASS PROPERTIES
------------------------------------------------------------
PositionClass.private	=	{
	POSITION_TO_STRING	=	{
		[0]		=	"Stretch to Output",
		[1]		=	"Stretch to Output with Aspect Ratio",
		[2]		=	"Stretch to Owner",
		[3]		=	"Stretch to Owner with Aspect Ratio",
		[4]		=	"Top Left",
		[5]		=	"Top Center",
		[6]		=	"Top Right",
		[7]		=	"Center Right",
		[8]		=	"Bottom Right",
		[9]		=	"Bottom Center",
		[10]	=	"Bottom Left",
		[11]	=	"Center Left",
		[12]	=	"Center",
		[13]	=	"Tile"
	}
};

------------------------------------------------------------
-- PRIVATE CLASS METHODS
------------------------------------------------------------

------------------------------------------------------------
-- PRIVATE OBJECT PROPERTIES
------------------------------------------------------------

------------------------------------------------------------
-- PRIVATE OBJECT METHODS
------------------------------------------------------------
